﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PicSolve
{
    public enum PValue
    {
        Unknown = 0,
        NoBox = 1,
        Box = 3
    }
    
    public class PLine
    {
        private PValue[] _content;
        public int Length { get { return _content.Length; } }

        public PLine(int length) : this(length, PValue.Unknown)
        {
        
        }


        public PLine(int length, PValue defaultvalue)
        {
            _content = new PValue[length];
            for (int i = 0; i < Length; i++)
            {
                _content[i] = defaultvalue;
            }
        }

        public PLine(string l)
        {
            _content = new PValue[l.Length];
            for (int i = 0; i < l.Length; i++)
            {
                _content[i] = l[i] == '1' ? PValue.Box : (l[i] == '0' ? PValue.NoBox : PValue.Unknown);
            }
        }

        public PValue this[int index]
        {
            get
            {
                return _content[index];
            }
            set
            {
                _content[index] = value;
            }
        }

        public override string ToString()
        {
            return string.Join("", _content.Select(b => b == PValue.Unknown ? '-' : (b == PValue.Box ? '1' : '0')));
        }
    }
}
